package com.lcc.bank.tools.listener;

import com.lcc.bank.tools.netty.NettyServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Service;

/**
 * @author lincc
 * @version 1.0  2019/2/22
 */
@Service
@Slf4j
public class ApplicationContextListener implements ApplicationListener<ContextRefreshedEvent> {

    @Autowired
    private NettyServer nettyServer;
    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        if (null == contextRefreshedEvent.getApplicationContext().getParent()) {
            log.info(">>>>> spring初始化完毕 <<<<<");
            nettyServer.init();
            log.info(">>>>> spring加载完毕 <<<<<");
        }
    }
}
